package ks.client;

import ks.client.ipc.Client;
import ks.managers.icon.IconManager;
import ks.managers.table.TableManager;
import ks.managers.plugin.PluginManager;
import ks.managers.user.UserManager;
import ks.server.ipc.Server;

/**
 * Records information about the user and machine to which the KombatSolitiare
 * is being connected.
 * <p>
 * This class also stores a reference to the actual {@link Client} object which
 * manages the communication with the server. This enables us to have multiple
 * client connection objects, which will help during testing.
 * <p>
 * This class will contain references to the key Managers on the client which will
 * enable two things. First, it will make it possible to rapidly find the appropriate
 * manager from within a controller. Second, it will do so in such a way that allows
 * us during testing to start up multiple clients so we can test our code. That is,
 * instead of using a Singleton Design pattern (where in the same test case all clients
 * would otherwise be sharing the same manager) we can ensure that each individually
 * connected client will have its own set of managers. 
 * 
 * @author George Heineman
 * @author Jennifer Hunt
 */
public class UserContext {

	/** Machine. */
	String host = "localhost";
	
	/** Port. */
	int port = Server.defaultPort;
	
	/** User info. */
	String user;
	
	/** User password. */
	String pass;
	
	/** Client object which manages all communication with remote server. */
	Client client;
	
	/** Whether this context was initiated anew by a brand new user. */
	boolean selfRegister = false;
	
	/** The Managers for this client connection. */
	final IconManager iconManager;
	final UserManager userManager;
	final TableManager tableManager;
	final PluginManager pluginManager;
	
	public UserContext() { 
		
		// extend as necessary with other managers.
		this.iconManager = new IconManager();
		this.userManager = new UserManager();
		this.tableManager = new TableManager();
		this.pluginManager = new PluginManager();
	}
	
	//Get user
	public String getUser() { return user; }
	//Set User
	public void setUser(String u) { user = u; }
	
	//Get a user's password
	public String getPassword() { return pass; }
	//Set a user's password
	public void setPassword(String p) { pass = p; }
	
	//Get the host
	public String getHost() { return host; }
	//Set the host
	public void setHost (String h) { host = h; }
	
	//Get the port
	public int getPort () { return port; }
	//Set the port
	public void setPort (int p) { port = p; }
	
	//Get the client
	public Client getClient() { return client; }
	//Set the client
	public void setClient (Client c) { client = c; }
	
	//Get self register
	public boolean getSelfRegister() { return selfRegister; }
	//Set self register
	public void setSelfRegister(boolean b) { selfRegister = b; }
	
	// Extend as necessary to retrieve managers.
	public IconManager getIconManager() { return iconManager; }
	public UserManager getUserManager() { return userManager; }
	public TableManager getTableManager(){return tableManager; }
	public PluginManager getPluginManager(){return pluginManager;}
}
